Skip to content

Conversation

@roiLeo
Copy link
Contributor

@roiLeo roiLeo commented Jun 23, 2025

@vikiival vikiival requested a review from Copilot November 10, 2025 11:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds collection-level statistics updates to the swap claim handler. When an NFT swap is claimed, the handler now calculates and updates the collection's floor price, owner count, and distribution metrics.

  • Imports helper functions for calculating collection floor and owner statistics
  • Calculates collection floor price after a swap is claimed
  • Calculates and updates collection owner count and distribution

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +39 to +48
const { floor } = await calculateCollectionFloor(context.store, collection.id, id)
const { ownerCount, distribution } = await calculateCollectionOwnerCountAndDistribution(
context.store,
collection.id,
event.currentOwner,
event.sent.owner
)
collection.floor = floor
collection.ownerCount = ownerCount
collection.distribution = distribution
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A swap involves two collections, but only the received collection's statistics are being updated. The sent collection (event.sent.collectionId) should also have its floor, ownerCount, and distribution recalculated and updated, as it loses an NFT owner and potentially gains a new one. This is inconsistent with how similar operations work - for example, in a swap, both NFTs change owners across potentially different collections.

Copilot uses AI. Check for mistakes.
collection.floor = floor
collection.ownerCount = ownerCount
collection.distribution = distribution
collection.updatedAt = event.timestamp
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updatedAt field is set twice: once on line 30 and again on line 49. The first assignment on line 30 is redundant since it gets overwritten. Consider removing the duplicate assignment on line 30.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant